<?php
/**********************************************************************************
WIKINDX: Bibliographic Management system.
Copyright (C)

This program is free software; you can redistribute it and/or modify it under the terms 
of the GNU General Public License as published by the Free Software Foundation; either 
version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; 
if not, write to the 
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

The WIKINDX Team 2007
sirfragalot@users.sourceforge.net
**********************************************************************************/
/*
* CMS hooks
*
* @author Mark Grimshaw
* @version 1
* $Header $
*/

// Check we have a sane environment or die
include("./config.php");
if(!isset($WIKINDX_CMS_ALLOW) || !isset($WIKINDX_CMS_BIBSTYLE))
	die("Missing configuration");

if(!$WIKINDX_CMS_ALLOW) // deny access
	die("CMS access denied");

include_once("core/cms/CMS.php");
include_once("core/sql/SQL.php");
$db = new SQL();

// Check if request is to parse text for [cite]...[/cite tags
if(($_GET['action'] == 'parseText') && (!array_key_exists('address', $_GET) || !$_GET['address']))
	die('Missing or incorrect queryString');
else if($_GET['action'] == 'parseText')
{
	if(isset($WIKINDX_SESSION_PATH) && $WIKINDX_SESSION_PATH && is_dir($WIKINDX_SESSION_PATH))
		session_save_path($WIKINDX_SESSION_PATH);
// start session (needed because CITESTYLE, BIBSTYLE etc use session variables to store the style file data
	session_start();
	$session = new SESSION();
	print CMS::parseText($db, $session, $WIKINDX_CMS_BIBSTYLE);
	die;
}
// Following for display of resources
list($sql, $limit) = CMS::getSql($db);
// Force HTTP to UTF-8 charset overriding any AddDefaultCharset set in Apache.
@header('Content-type: text/html; charset=utf-8');
print CMS::queryDb($db, $sql, $WIKINDX_CMS_BIBSTYLE, $limit);
die;

/**
END SCRIPT
*/

?>